<!DOCTYPE html><html><head><meta content=yes name=apple-mobile-web-app-capable><meta name=viewport content="width=device-width,height=device-height,initial-scale=1,maximum-scale=1,user-scalable=no"><meta charset=utf-8><meta http-equiv=Expires content=0><meta http-equiv=Cache-Control content=no-cache><meta http-equiv=Pragma content=no-cache><link rel="shortcut icon" type=image/x-icon href=./static/favicon.ico rel="external nofollow"><title>商派</title><link href=./static/css/app.513591a4d7dfdccbaa202f8bde544979.css rel=stylesheet></head><body><div id=app></div><script>document.write("<s" + "cript type='text/javascript' src='./static/config.js?" + (new Date()).valueOf() + "'></scr" + "ipt>");</script><script>var messagingIframe;
		var sendMessageQueue = [];
		var receiveMessageQueue = [];
		var messageHandlers = {};

		var PVG_CUSTOM_PROTOCOL_SCHEME = 'wvjbscheme';
		var QUEUE_HAS_MESSAGE = '__QUEUE_MESSAGE__/';
		var QUEUE_HAS_MESSAGE_IOS = '__WVJB_QUEUE_MESSAGE__';
		var QUEUE_HAS_MESSAGE_LOAD = '__BRIDGE_LOADED__';

		var responseCallbacks = {};
		var uniqueId = 1;

		function _createQueueReadyIframe(doc) {
			messagingIframe = doc.createElement('iframe');
			messagingIframe.style.display = 'none';
			messagingIframe.src = PVG_CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE_LOAD
			doc.documentElement.appendChild(messagingIframe);
		}

		function isAndroid() {
			var ua = navigator.userAgent.toLowerCase();
			var isA = ua.indexOf("android") > -1;
			if (isA) {
				return true;
			}
			return false;
		}

		function isIphone() {
			var ua = navigator.userAgent.toLowerCase();
			var isIph = ua.indexOf("iphone") > -1;
			if (isIph) {
				return true;
			}
			return false;
		}

		function isWeixin() {
			var ua = navigator.userAgent.toLowerCase();
			if (ua.match(/MicroMessenger/i) == "micromessenger") {
				return true;
			} else {
				return false;
			}
		}

		function isInApp() {
			var ua = navigator.userAgent.toLowerCase();
			//alert(ua);
			var isIph = ua.indexOf("wenchao/") > -1;
			if (isIph) {
				return true;
			}
			return false;
		}

		//set default messageHandler
		function init(messageHandler) {
			if (WebViewJavascriptBridge._messageHandler) {
				throw new Error('WebViewJavascriptBridge.init called twice');
			}
			WebViewJavascriptBridge._messageHandler = messageHandler;
			// if(!receiveMessageQueue){
			//     return;
			// }
			var receivedMessages = receiveMessageQueue;
			// receiveMessageQueue = null;
			for (var i = 0; i < receivedMessages.length; i++) {
				_dispatchMessageFromNative(receivedMessages[i]);
			}
		}

		function send(data, responseCallback) {
			_doSend({
				data: data
			}, responseCallback);
		}

		function registerHandler(handlerName, handler) {
			messageHandlers[handlerName] = handler;
		}

		function callHandler(handlerName, data, responseCallback) {
			_doSend({
				handlerName: handlerName,
				data: data
			}, responseCallback);
		}

		//sendMessage add message, 触发native处理 sendMessage
		function _doSend(message, responseCallback) {
			if (responseCallback) {
				var callbackId = 'cb_' + (uniqueId++) + '_' + new Date().getTime();
				responseCallbacks[callbackId] = responseCallback;
				message.callbackId = callbackId;
			}

			sendMessageQueue.push(message);

			if (isIphone()) {
				messagingIframe.src = PVG_CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE_IOS;
			} else if (isAndroid()) {
				messagingIframe.src = PVG_CUSTOM_PROTOCOL_SCHEME + '://' + QUEUE_HAS_MESSAGE;
			}
		}

		// 提供给native调用,该函数作用:获取sendMessageQueue返回给native,由于android不能直接获取返回的内容,所以使用url shouldOverrideUrlLoading 的方式返回内容
		function _fetchQueue() {
			var messageQueueString = JSON.stringify(sendMessageQueue);
			sendMessageQueue = [];
			//add by hq
			if (isIphone()) {
				return messageQueueString;
				//android can't read directly the return data, so we can reload iframe src to communicate with java
			} else if (isAndroid()) {
				messagingIframe.src = PVG_CUSTOM_PROTOCOL_SCHEME + '://return/_fetchQueue/' + encodeURIComponent(messageQueueString);
			}
		}

		//提供给native使用,
		function _dispatchMessageFromNative(messageJSON) {
			setTimeout(function () {
				var message = JSON.parse(messageJSON);
				var responseCallback;
				//java call finished, now need to call js callback function
				if (message.responseId) {
					responseCallback = responseCallbacks[message.responseId];
					if (!responseCallback) {
						return;
					}
					responseCallback(message.responseData);
					delete responseCallbacks[message.responseId];
				} else {
					//直接发送
					if (message.callbackId) {
						var callbackResponseId = message.callbackId;
						responseCallback = function (responseData) {
							_doSend({
								responseId: callbackResponseId,
								responseData: responseData
							});
						};
					}

					var handler = WebViewJavascriptBridge._messageHandler;
					if (message.handlerName) {
						handler = messageHandlers[message.handlerName];
					}
					//查找指定handler
					try {

						handler(message.data, responseCallback);
					} catch (exception) {
						if (typeof console != 'undefined') {
							console.log("WebViewJavascriptBridge: WARNING: javascript handler threw.", message, exception);
						}
					}
				}
			});
		}

		//提供给native调用,receiveMessageQueue 在会在页面加载完后赋值为null,所以
		function _handleMessageFromNative(messageJSON) {
			// if (receiveMessageQueue) {
			//     receiveMessageQueue.push(messageJSON);
			// } else {
			_dispatchMessageFromNative(messageJSON);
			// }
		}

		function _handleMessageFromObjC(messageJSON) {

			_dispatchMessageFromNative(messageJSON)
		}

		var WebViewJavascriptBridge = window.WebViewJavascriptBridge = {
			isInApp: isInApp,
			isIphone: isIphone,
			isAndroid: isAndroid,
			isWeixin: isWeixin,
			init: init,
			send: send,
			registerHandler: registerHandler,
			callHandler: callHandler,
			_fetchQueue: _fetchQueue,
			_handleMessageFromNative: _handleMessageFromNative,
			_handleMessageFromObjC: _handleMessageFromObjC
		};

		var doc = document;
		_createQueueReadyIframe(doc);
		var readyEvent = doc.createEvent('Events');
		readyEvent.initEvent('WebViewJavascriptBridgeReady');
		readyEvent.bridge = WebViewJavascriptBridge;
		doc.dispatchEvent(readyEvent);


		function connectWebViewJavascriptBridge(callback) {
			if (window.WebViewJavascriptBridge) {
				callback(WebViewJavascriptBridge)
			} else {
				document.addEventListener('WebViewJavascriptBridgeReady', function () { callback(WebViewJavascriptBridge) }, false);
			}
		}

		connectWebViewJavascriptBridge(function (bridge) {
			bridge.init();
		});

		var wenchaoApp = {

			// callHander

			openLink: function (link, callback) {
				window.WebViewJavascriptBridge.callHandler('openLink', link, callback)
			},

			checkInApp: function (callback) {
				window.WebViewJavascriptBridge.callHandler('checkInApp', { needResult: 1 }, callback);
			},

			doLogin: function () {
				window.WebViewJavascriptBridge.callHandler('doLogin', { needResult: 1 });
			},

			getToken: function (callback) {
				window.WebViewJavascriptBridge.callHandler('getToken', { needResult: 1 }, callback);
			},

			addCartSucceed: function () {
				window.WebViewJavascriptBridge.callHandler('addCartSucceed', { needResult: 1 });
			},

			// registerHandler
			onLogin: function (callback) {
				window.WebViewJavascriptBridge.registerHandler('onLogin', callback);
			},
		};

		window.wenchaoApp = wenchaoApp;</script><script type=text/javascript src=./static/js/manifest.10257a646405184d7d4f.js></script><script type=text/javascript src=./static/js/vendor.942ce2b910a0309ffb6f.js></script><script type=text/javascript src=./static/js/app.1583ffb954425a383515.js></script></body></html>